<?php #//AJAX PHP PENNY AUCTION v.1.3

#///////////////////////////////////////////////////////////
#//  COPYRIGHT 2009 Aaron Helmlinger ALL RIGHTS RESERVED  //
#///////////////////////////////////////////////////////////
   require('./includes/config.inc.php');
   
    $TIME = mktime(date("H")+$SETTINGS['timecorrection'],date("i"),date("s"),date("m"), date("d"),date("Y"));

$NOW = date("YmdHis",$TIME);
               
                $query_settings = "select * from PHPAUCTIONXL_version_1_3 where id='1'";
                             $query_settings2 =  mysql_query ($query_settings);
                                $closed_auctions2 = mysql_result($query_settings2,0,"closed_auctions");

$sql_count_upcoming = "SELECT * FROM PHPAUCTIONXL_auctions 
				WHERE  
				( closed='0')  
				AND ( suspended='0') 
				AND private='n' 
				AND	starts>=".$NOW." 
				ORDER BY id";
				
				$result1 = mysql_query($sql_count_upcoming);
$total_upcoming = mysql_num_rows($result1);

$sql_count_live = "SELECT * FROM PHPAUCTIONXL_auctions 
				WHERE  
				( closed='0')  
				AND ( suspended='0') 
				AND private='n' 
				AND	starts<=".$NOW." 
				ORDER BY id";
				
							$result2 = mysql_query($sql_count_live);
$total_live = mysql_num_rows($result2);	
				

$sql_count_closed = "select ends,id,title,current_high_bidder,current_bid,pict_url,retail,suspended,reserve_price from PHPAUCTIONXL_auctions
         WHERE closed='1' AND suspended='0' AND current_bid > 0 AND retail > 0 AND current_bid > reserve_price ORDER BY ends DESC LIMIT 0,100";
	
							$result3 = mysql_query($sql_count_closed);
$total_closed = mysql_num_rows($result3);	

    $query = 




$upcoming_page = $_GET['upcoming_page'];
$live_page = $_GET['live_page'];
$closed_page = $_GET['closed_page'];

if ( !$upcoming_page ) {

$upcoming_page = 1;
  
}  

if ( !$live_page ) {

$live_page = 1;
  
} 

if ( !$closed_page ) {

$closed_page = 1;
  
} 

        
        
   if ( $total_upcoming > $SETTINGS['lastitemsnumber'] ) {
$pages_upcoming = $total_upcoming / $SETTINGS['lastitemsnumber'];
          $pages_upcoming = ceil($pages_upcoming);
    $previous_upcoming_page = $upcoming_page - 1; 
     
   $pagination_upcoming = " ";
      if ( $previous_upcoming_page != 0 ) {
    $pagination_upcoming .= "<span CLASS=PREVIOUS_PAGE ><A HREF=\"view_all_live_auctions_iphone.php?upcoming_page=$previous_upcoming_page\">$PREVIOUS</A></span>";
        }
  

$i = 0;
$ii = 1;
while ( $i < $pages_upcoming ) {


  if ( $ii == $upcoming_page ) { 
$pagination_upcoming .= "<span CLASS=PAGE_CURRENT ><A HREF=\"view_all_live_auctions_iphone.php?upcoming_page=$ii\">$ii</A></span>";
}    
  
  if ( $ii != $upcoming_page ) {
$pagination_upcoming .= "<span CLASS=PAGE ><A HREF=\"view_all_live_auctions_iphone.php?upcoming_page=$ii\">$ii</A></span>";
     }

$i++;
$ii++;

}

 $next_upcoming_page = $upcoming_page + 1; 
     

      if ( $next_upcoming_page == $pages_upcoming ) {
    $pagination_upcoming .= "<span CLASS=NEXT_PAGE ><A HREF=\"view_all_live_auctions_iphone.php?upcoming_page=$next_upcoming_page\">$NEXT</A></span>";
        }

      //$pagination_upcoming .= "<span CLASS=NEXT_PAGE ><A HREF=\"view_all_upcoming_auctions.php\">$VIEW_ALL</A></span>";
    

}  
   
  
      //echo $total_live;
      //echo $SETTINGS['endingsoonnumber'];
  if ( $total_live > $SETTINGS['endingsoonnumber'] ) {
$pages_live = $total_live / $SETTINGS['endingsoonnumber'] ;
    
$pages_live = ceil($pages_live);
    
    $previous_live_page = $live_page - 1; 

   $pagination_live = " ";
      if ( $previous_live_page != 0 ) {
    $pagination_live .= "<span CLASS=PREVIOUS_PAGE ><A HREF=\"view_all_live_auctions_phone.php?live_page=$previous_live_page\" class=FOOTERLINKS1 >$PREVIOUS</A></span>";
        }


$i = 0;
$ii = 1;
while ( $i < $pages_live ) {


  if ( $ii == $live_page ) { 
$pagination_live .= "<span CLASS=PAGE_CURRENT ><A HREF=\"view_all_live_auctions_phone.php?live_page=$ii\"  class=FOOTERLINKS1 >$ii</A></span>";
}    
  
  if ( $ii != $live_page ) {
$pagination_live .= "<span CLASS=PAGE ><A HREF=\"view_all_live_auctions_phone.php?live_page=$ii\"  class=FOOTERLINKS1 >$ii</A></span>";
     }

$i++;
$ii++;

}

 
     
      $next_live_page = $live_page + 1; 
      if ( $next_live_page == $pages_live ) {
       
    $pagination_live .= "<span CLASS=NEXT_PAGE ><A HREF=\"view_all_live_auctions_phone.php?live_page=$next_live_page\"  class=FOOTERLINKS1 >$NEXT </A></span>";
        }
           // $pagination_live .= "<span CLASS=NEXT_PAGE ><A HREF=\"view_all_live_auctions.php\">$VIEW_ALL</A></span>";
}    



				
    if ( $closed_auctions2 == "" ) {
              $closed_auctions2 = 6;
    }

   if ( $total_closed >  $closed_auctions2 ) {
$pages_closed = $total_closed /  $closed_auctions2;
        $pages_closed = floor($pages_closed);
    $previous_closed_page = $closed_page - 1; 
     
   $pagination_closed = " ";
      if ( $previous_closed_page != 0 ) {
    $pagination_closed .= "<span CLASS=PREVIOUS_PAGE ><A HREF=\"view_all_live_auctions_iphone.php?closed_page=$previous_closed_page\">$PREVIOUS</A></span>";
        }


$i = 0;
$ii = 1;
while ( $i < $pages_closed ) {


  if ( $ii == $closed_page ) { 
$pagination_closed .= "<span CLASS=PAGE_CURRENT ><A HREF=\"view_all_live_auctions_iphone.php?closed_page=$ii\">$ii</A></span>";
}    
  
  if ( $ii != $closed_page ) {
$pagination_closed .= "<span CLASS=PAGE ><A HREF=\"view_all_live_auctions_iphone.php?closed_page=$ii\">$ii</A></span>";
     }

$i++;
$ii++;

}

 $next_closed_page = $closed_page + 1; 
     
      if ( $next_closed_page > 1 && $pages_closed != $closed_page ) {
    $pagination_closed .= "<span CLASS=NEXT_PAGE ><A HREF=\"view_all_live_auctions_iphone.php?closed_page=$next_closed_page\">$NEXT</A></span>";
        }

}  

 

// echo $pagination_upcoming;
// echo $pagination_live;
//echo $pagination_closed;

?>
